package com.example.order.controller;

import com.example.feign.bo.Person01BO;
import com.example.feign.clients.UserClientFeignApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/feign")
@ResponseBody
public class OpenFeignController {
    @Autowired
    private UserClientFeignApi userClientFeignApi;

    @GetMapping(value = "/select/{id}")
    public Person01BO getAllPerson01BO(@PathVariable("id")String id) {
        System.out.println("api : /feign/select/{id}");
        List<Person01BO> select = userClientFeignApi.select(id);
        System.out.println(select.get(0));
        return select.get(0);
    }

    @GetMapping(value = "/hystrix")
    public String testHytrix() {
        System.out.println("api : /feign/hystrix");
        String result = userClientFeignApi.testHystrix();
        return result;
    }


    @GetMapping(value = "/sentinel")
    public String testSentinel() {
        System.out.println("api : /feign/hystrix");
        String result = userClientFeignApi.testSentinel();
        return result;
    }
}
